﻿<UserControl x:Class="SoftSource.Timecard.Views.ProjectEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:converters="clr-namespace:SoftSource.Timecard.Converters"
             xmlns:softsourceConverters="clr-namespace:SoftSource.Common.Converters;assembly=SoftSource.Common.Silverlight"
             xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
             xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
             xmlns:dataform="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             d:DesignWidth="463"
             d:DesignHeight="378">

    <UserControl.Resources>
        <softsourceConverters:ObjectToVisibilityConverter x:Name="ObjectToVisibilityConverter" />
        <softsourceConverters:EnumToDisplayNamePairConverter x:Key="EnumToDisplayNamePairConverter" />
        <softsourceConverters:EnumToDisplayNamePairCollectionConverter x:Key="EnumToDisplayNamePairCollectionConverter" />
        <softsourceConverters:FormattedDateConverter x:Key="FormattedDateConverter" />
        <converters:ObjectToManagerListConverter x:Key="ObjectToManagerListConverter" />
    </UserControl.Resources>

    <controlsToolkit:BusyIndicator x:Name="Busy"
                                   HorizontalContentAlignment="Stretch"
                                   VerticalContentAlignment="Stretch">
        <Grid x:Name="LayoutRoot">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <dataform:DataForm x:Name="ProjectDataForm"
                               CurrentItem="{Binding Project}"
                               AutoCommit="False"
                               AutoGenerateFields="False"
                               AutoEdit="True"
                               CommandButtonsVisibility="None">
                <dataform:DataForm.EditTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <dataform:DataField>
                                <TextBox Text="{Binding Name, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <TextBox Text="{Binding EstDuration, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <TextBox Text="{Binding ProjectCode, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <controls:DatePicker SelectedDate="{Binding EstCompletionDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <TextBox IsEnabled="False"
                                         Text="{Binding BilledAsOf, Converter={StaticResource FormattedDateConverter}, Mode=OneWay}" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <ComboBox x:Name="ProjectManagerCombobox"
                                          DisplayMemberPath="FullName"
                                          ItemsSource="{Binding Mode=OneWay, Source={StaticResource Managers}}"
                                          SelectedItem="{Binding ManagerUserID, Converter={StaticResource UserIDConverter}, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                                          Height="20"
                                          VerticalAlignment="Bottom" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <ComboBox x:Name="ProjectTypeCombobox"
                                          DisplayMemberPath="Name"
                                          ItemsSource="{Binding Mode=OneWay, Source={StaticResource ProjectTypes}}"
                                          SelectedItem="{Binding ProjectTypeID, Converter={StaticResource ProjectTypeIDConverter}, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                                          Height="20"
                                          VerticalAlignment="Bottom" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <ComboBox x:Name="RevenueTypeCombobox"
                                          DisplayMemberPath="Description"
                                          ItemsSource="{Binding Mode=OneWay, Source={StaticResource RevenueTypes}}"
                                          SelectedItem="{Binding RevenueTypeID, Converter={StaticResource RevenueTypeIDConverter}, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                                          Height="20"
                                          VerticalAlignment="Bottom" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <ComboBox x:Name="StatusCombobox"
                                          DisplayMemberPath="Description"
                                          ItemsSource="{Binding Mode=OneWay, Source={StaticResource ProjectStatuses}}"
                                          SelectedItem="{Binding StatusID, Converter={StaticResource ProjectStatusIDConverter}, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                                          Height="20"
                                          VerticalAlignment="Bottom" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <ComboBox x:Name="BillingFrequencyCombobox"
                                          DisplayMemberPath="Frequency"
                                          ItemsSource="{Binding Mode=OneWay, Source={StaticResource BillingFrequencies}}"
                                          SelectedItem="{Binding BillingFrequencyID, Converter={StaticResource BillingFrequencyIDConverter}, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                                          Height="20"
                                          VerticalAlignment="Bottom" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <TextBox Text="{Binding Description, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                            </dataform:DataField>
                        </StackPanel>
                    </DataTemplate>
                </dataform:DataForm.EditTemplate>
            </dataform:DataForm>

            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="75" />
                    <ColumnDefinition MinWidth="75" />
                    <ColumnDefinition MinWidth="75" />
                    <ColumnDefinition MinWidth="75" />
                    <ColumnDefinition MinWidth="75" />
                </Grid.ColumnDefinitions>

                <Button x:Name="SaveButton"
                        Grid.Column="0"
                        Content="Save"
                        Click="Save_Click"
                        Margin="4" />
                <Button x:Name="ApplyButton"
                        Grid.Column="1"
                        Content="Apply"
                        Click="Apply_Click"
                        Margin="4" />
                <Button x:Name="CancelButton"
                        Grid.Column="2"
                        Content="Cancel"
                        Click="Cancel_Click"
                        Margin="4" />
                <Button x:Name="EditMembersButton"
                        Grid.Column="3"
                        Content="Edit Members"
                        Click="EditMembers_Click"
                        Margin="4"
                        Visibility="{Binding CreateEditMembers, Converter={StaticResource ObjectToVisibilityConverter}}" />
                <Button x:Name="EditCategoriesButton"
                        Grid.Column="4"
                        Content="Edit Categories"
                        Click="EditCategories_Click"
                        Margin="4"
                        Visibility="{Binding CreateEditCategories, Converter={StaticResource ObjectToVisibilityConverter}}" />
            </Grid>
        </Grid>
    </controlsToolkit:BusyIndicator>
</UserControl>